package com.mall.service.impl;

import com.mall.common.utils.Convert;
import com.mall.common.utils.Security;
import com.mall.dao.custom.CtCategoryMapper;
import com.mall.entity.Category;
import com.mall.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author xyl
 * @date 2021-02-10 16:56
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CtCategoryMapper categoryMapper;

    @Override
    public int add(Category category) {
        category.setCreateTime(new Date());
        category.setCreateBy(Security.getCurrentUserId());
        return categoryMapper.insert(category);
    }

    @Override
    public List<Category> getAll() {
        return categoryMapper.selectAll();
    }

    @Override
    public int removeByIds(String ids) {
        return categoryMapper.deleteByIds(Convert.toIntArray(ids));
    }
}
